#ifndef __YX020_PORT_H
#define __YX020_PORT_H

#include "stdint.h"

typedef enum {
    YX020_BROAD_REG0 = 0x61,
    YX020_BROAD_REG1 = 0x63,
    YX020_BROAD_REG2 = 0x65,
    YX020_BROAD_REG3 = 0x67,
    YX020_BROAD_REG4 = 0x69,
    YX020_BROAD_REG5 = 0x6B,
    YX020_BROAD_REG6 = 0x6D,
    YX020_BROAD_REG7 = 0x6F
} YX020_BROAD_REG_E;

typedef enum {
    YX020_WSELECT_REG0 = 0x60,
    YX020_WSELECT_REG1 = 0x62,
    YX020_WSELECT_REG2 = 0x64,
    YX020_WSELECT_REG3 = 0x66,
    YX020_WSELECT_REG4 = 0x68,
    YX020_WSELECT_REG5 = 0x6A,
    YX020_WSELECT_REG6 = 0x6C,
    YX020_WSELECT_REG7 = 0x6E
} YX020_WSELECT_REG_E;

void sendFrameHead(uint8_t reg4, uint8_t reg7, uint8_t tm);
void sendCMD2S(void);
void sendCMD2D(void);
void sendVSYNC(void);
void sendSetBaud(void);
void sendSetID(uint16_t num);
void onlySendSetID(uint16_t num);
void sendBrightness(uint16_t startID, const uint16_t *brData, uint16_t brLen);
void sendBrightness8bit(uint16_t startID, const uint8_t *brData, uint16_t brLen);
void YX020SendF579(uint8_t reg4, uint16_t chipNum, uint8_t btm, uint8_t reg7);
void broadcastBrightness(uint16_t *brData, uint8_t vsync);
void readReg(uint16_t id, uint8_t reg);
void YX020BroadcastReg(YX020_BROAD_REG_E reg, uint8_t val);
void YX020BroadcastFrame(const uint8_t *regList, const uint16_t *brData, uint8_t tm, uint8_t btm, uint8_t bit8Mode, uint8_t lowiq, uint32_t pdTime);
void YX020WriteSelectReg(YX020_WSELECT_REG_E reg, uint8_t val, uint16_t id, uint8_t cmd2s);
void testmodeBKWBoard(uint16_t chipNum, uint8_t reg0);
void YX020InitAndSetup(uint8_t reg4, uint16_t chipNum, uint8_t btm, uint8_t reg7, uint8_t cmd2d);
void YX020Frame(const uint8_t *regList, const uint16_t *brData, uint16_t brLen, uint16_t startID, uint8_t tm, uint8_t btm, uint8_t bit8Mode, uint8_t lowiq, uint32_t pdTime);
void YX020HLBuadFrame(const uint8_t *regList, const uint16_t *brData, uint16_t brLen, uint16_t startID, uint8_t tm, uint8_t btm, uint8_t bit8Mode, uint8_t lowiq, uint32_t pdTime, uint8_t isF0, uint32_t lowBaud, uint32_t hightBaud);

void YX020TestMode5(uint8_t reg6);
void YX020TestMode6(void);

#endif
